package com.yzpass.api.common.util;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

import java.util.UUID;

public class AuthUtil {
    public static UUID currentUserId(){
        String accessToken = null;
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        if (requestAttributes != null) {
            if (requestAttributes.getAttribute("userId", RequestAttributes.SCOPE_REQUEST) != null) {
                return  (UUID) requestAttributes.getAttribute("userId", RequestAttributes.SCOPE_REQUEST);
            }
        }
        return null;
    }
}
